package zhc.framework.view.beetl;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.beetl.core.Context;
import org.beetl.core.Function;

import java.io.IOException;
/**
 * long 格式化为日期
 * @author hu
 *
 */
public class LongToDate implements Function{
        public String call(Object[] paras, Context ctx){
                Long o=(Long)paras[0];
                String f="yyyy-MM-dd HH:mm:ss";
                if(paras.length>1){
                	f=(String)paras[1];
                }
                if (o != null){
                        try{
                                ctx.byteWriter.write(DateFormatUtils.format(o*1000l, f).getBytes());
                        }catch (IOException e){
                                throw new RuntimeException(e);
                        }
                }
                return "";
        }
}